
/*!
 * 
 * dialog javascript
 * 
 */
$(function() {
		// a workaround for a flaw in the demo system (http://dev.jqueryui.com/ticket/4375), ignore!
		$( "#dialog:ui-dialog" ).dialog( "destroy" );
		
		$( "#roleAddDialog-form" ).dialog({
			autoOpen: false,
			height: 350,
			width: 440,
			modal: true,
			buttons: {
				"是的": function() {
					alert("设置成功！");
					$("#addForm").submit(addFormCollecter());
					$( this ).dialog( "close" );
					return false;
				},
				"算了": function() {
					$( this ).dialog( "close" );
					return false;
				}
			},
			close: function() {
				$("#r").empty();
			}
		});
		
		$( ".roleAddDialog" ).click(function() {
			$( "#roleAddDialog-form" ).dialog( "open" );
			$.post("ajax/resource_list.do", null, function(jsonData) {
				var resList = jsonData.resourceList;
  				for(var i in resList) {
  					$("#r").append("<input type='checkbox' name='res_id' value='" + resList[i].id + "' />&nbsp;" + resList[i].name + "&nbsp;");
  					if((i+1)%3 == 0)
  						$("#r").append("<br>");
  				}
   			}, "json");	
		});
});